package com.ai.file;

/**
 * @author: heJinQin
 * @create: 2024-03-03 22:37
 * @description:
 **/

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
import org.json.JSONObject;

public class FileConverter {
    public static void txtToJsonl(String inputFilePath, String outputFilePath) {
        try (BufferedReader br = new BufferedReader(new FileReader(inputFilePath));
             PrintWriter pw = new PrintWriter(new FileWriter(outputFilePath))) {
            String line;
            while ((line = br.readLine()) != null) {
                JSONObject json = new JSONObject();
                json.put("text", line);
                pw.println(json.toString());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        String inputFilePath = "C:\\Users\\14550\\Desktop\\loadCookie.txt";
        String outputFilePath = "C:\\Users\\14550\\Desktop\\output.jsonl";
        txtToJsonl(inputFilePath, outputFilePath);
    }
}
